<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // function getLonestTime(arr) {
      //   let n = arr.length
      //   let arr1 = []
      //   if (n === 0) {
      //     return 0
      //   } else if (n === 1) {
      //     return n
      //   }
      //   arr1[0] = arr[0]
      //   arr1[1] = Math.max(arr[0], arr[1])
      //   for (let i = 2; i < n; i++) {
      //     arr1[i] =
      //       arr1[i - 1] >= arr1[i - 2] + arr[i]
      //         ? arr1[i - 1]
      //         : arr1[i - 2] + arr[i]
      //   }
      //   return arr1[n - 1]
      // }
      // console.log(getLonestTime([2, 7, 9, 3, 1]))  b

      
      function getSum(n) {
        arr = [1, 2]
        for (let i = 2; i < n; i++) {
          arr[i] = arr[i - 1] + arr[i - 2]
        }
        return arr[n]
      }
      console.log(getSum(20))
    </script>
  </body>
</html>
